import socket


ip_port: str = ''
g_port: str = ''


def __get_ip() -> str:
    """
    获取ip

    :return: ip字符串
    """
    return socket.gethostbyname(socket.gethostname())


def set_ip_port(port: int):
    """
    设置ip和端口

    :param port: 端口
    :return:
    """
    global ip_port
    global g_port
    g_port = port
    ip_port = f'{__get_ip()}:{port}'


def get_ip_port() -> str:
    """
    获取ip和端口

    :return: ip:端口字符串
    """
    return ip_port


def get_port() -> str:
    """
    获取端口

    :return: 端口字符串
    """
    return g_port
